<template>
	<view class="page-root">
		<nav-bar>
			图纸
		</nav-bar>

<!-- 		<view class="search-lay">
			<view class="search_box">
				<image class="search_icon" :src="searchIconUrl"></image>
				<input v-model="strInput" class="search_tip" placeholder="输入搜索内容" confirm-type="search" @confirm="onSearchClick"></input>
			</view>
		</view> -->

		<scroll-view>
			<view class="doc-item" v-for="(item,index) in dataList" :key="index">
				<image class="item-type-img" :src="docIconUrl"></image>
				<view style="width: 60vw;" @click="onItemClick(item)">
					<view class="item-name">{{item.Name}}</view>
					<view class="item-desc">{{item.SerialNumber}}</view>
				</view>
				<image class="item-image" :src="moreIconUrl" @click="onItemMoreClick(item)"></image>
			</view>
			<view style=" height: 250upx;"></view>
		</scroll-view>

		<!-- info -->
		<uni-popup ref="infoPopup" type="bottom" :animation="true">
			<view class="info-content">
				<view class="head-file">
					<view class="pop-head-img"></view>
					<view class="pop-head-name">图纸详情</view>
				</view>
				<view class="info-cutoff"></view>

				<view>
					<view class="info-line">
						<view class="info-title">图纸编号</view>
						<view class="info-value">{{selectedItem.SerialNumber}}</view>
					</view>
					<view class="info-line">
						<view class="info-title">图纸名称</view>
						<view class="info-value">{{selectedItem.Name}}</view>
					</view>
					<view class="info-line">
						<view class="info-title">创建时间</view>
						<view class="info-value">{{selectedItem.CreateTime}}</view>
					</view>
				</view>
			</view>
		</uni-popup>

	</view>
</template>

<script>
	// import test_datalist from "@/common/test_jsons/test_datalist.js"
	import CONSTS from '@/common/biz/consts.js'

	import {
		getCadListPage
	} from "@/services/drawing.js"

	export default {
		data() {
			return {
				messageIconUrl: '/static/' + 'icon_navigation_news.png',
				moreIconUrl: '/static/' + 'instrument_more.png',
				searchIconUrl: '/static/' + 'icon_search.png',
				docIconUrl: '/static/' + 'icon_svg.png',
				dataList: [],

				selectedItem: {},

				status: 'more',
				contentText: {
					contentdown: '上拉加载更多',
					contentrefresh: '加载中',
					contentnomore: '没有更多'
				},

				strInput: "",
			}
		},

		onLoad(e) {
			this.reLoadListData();
		},

		onReachBottom() {
			this.status = 'more';
			this.getCadList(this.searchPage + 1);
		},
		methods: {
			onSearchClick(e) {

			},

			onItemMoreClick(e) {
				this.$refs.infoPopup.open();
				this.selectedItem = e;
			},

			reLoadListData() {
				this.searchPage = 0;
				this.docList = [];
				this.selectDocIds = [];
				this.getCadList(this.searchPage + 1);
			},

			getCadList(inPage) {
				uni.showLoading({
					title: '加载中'
				})
				getCadListPage({
					page: inPage,
					limit: CONSTS.PAGE_DEFAULT_LIMIT,
					BitNumber: "",
					MileageID: CONSTS.DEFAULT_MODEL_ID,
				}).then((res) => {
					if (res.code == '000000') {
						// debugger
						if (inPage == 0)
							this.docList = [];
						let tempData = res.data;
						this.dataList = this.dataList.concat(tempData);
						this.searchPage = this.searchPage + 1;
					} else {

					}
					uni.hideLoading();
				});
			},

			onItemClick(e) {
				uni.navigateTo({
					url: '/pages/drawing/drawingShow?url=' + e.PathUrl + '&title=' + e.Name
				})
			}
		}
	}
</script>

<style scoped lang='scss'>
	.page-root {
		background: #F8F8F8;

	}

	.right_icon {
		width: 32upx;
		height: 32upx;
		padding: 15upx;
		border-radius: 25px;
		border: 1px solid rgba(255, 255, 255, 1.0);
		margin-right: 20upx;
		background-color: #FFFFFF;
	}

	.head-view {
		display: flex;
		flex-direction: row;
		align-items: center;
		padding: 32upx;
	}

	.head-icon {
		width: 4upx;
		height: 28upx;
		background: linear-gradient(180deg, #259DB7 0%, #016A9B 100%);
		border-radius: 1px;
	}

	.head-title {
		font-size: 18px;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 500;
		color: rgba(0, 0, 0, 0.85);
		line-height: 20px;
		margin-left: 16upx;
	}


	.doc-item {
		background: #FCFCFC;
		box-shadow: 0px 1px 7px 0px rgba(84, 84, 84, 0.05);
		border-radius: 2px;
		margin: 24upx 12upx 24upx 12upx;
		padding: 32upx;

		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
	}

	.item-type-img {
		width: 64upx;
		height: 64upx;
	}

	.item-name {
		font-size: 32upx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 500;
		color: rgba(0, 0, 0, 0.65);
		line-height: 40px;
	}

	.item-desc {
		font-size: 24upx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #999999;
		line-height: 48upx;

	}

	.item-image {
		width: 44upx;
		height: 44upx;
	}


	.info-content {
		padding: 32upx;
		background: #FFFFFF;
		border-radius: 10px 10px 0px 0px;
	}

	.head-file {
		display: flex;
		flex-direction: row;
		align-items: center;
	}

	.pop-head-img {
		width: 4upx;
		height: 28upx;
		background: #327FFC;
		border-radius: 2px;
	}

	.pop-head-name {
		font-size: 36upx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 500;
		color: rgba(0, 0, 0, 0.85);
		line-height: 40px;
		margin-left: 20upx;
	}

	.item-name {
		font-size: 16px;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: rgba(0, 0, 0, 0.65);
		line-height: 22px;
	}

	.info-cutoff {
		height: 1px;
		background: rgba(0, 0, 0, 0.07);
		box-shadow: 0px 1px 0px 0px #FFFFFF;
		margin-top: 32upx;
		margin-bottom: 32upx;
	}

	.info-title {
		font-size: 14px;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: rgba(0, 0, 0, 0.85);
		line-height: 17px;
	}

	.info-value {
		font-size: 12px;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: rgba(0, 0, 0, 0.45);
		line-height: 17px;
	}

	.info-line {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		padding: 24upx;
	}

	.search-lay {
		/* width: 100%; */
		background: #FFFFFF;
		box-shadow: 0px 2px 8px 0px rgba(0, 0, 0, 0.2);
		padding: 12upx 32upx 12upx 32upx;

	}

	.search_box {
		height: 64upx;
		background: rgba(0, 0, 0, 0.04);
		border-radius: 8px;
		filter: blur(0px);

		padding-left: 12upx;
		display: flex;
		flex-direction: row;
		align-items: center;
	}

	.search_tip {
		height: 17px;
		font-size: 12px;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #000;
		line-height: 17px;
	}

	.search_icon {
		width: 40upx;
		height: 40upx;
	}
</style>
